<template>
    <div>
        <div class="crumbs">
            <el-breadcrumb separator="/">
                <el-breadcrumb-item>
                    <div class="contentsize">财务确认-经理部</div>
                </el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="container">
            <div class="handle-box">
                <el-form ref="form" :model="form" label-width="80px" :inline="true" size="mini">
                    <el-form-item label="承租单位:">
                        <div style="width: 160px">
                            <el-input v-model="form.czr" placeholder="请输入承租单位" clearable @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="合同编号:">
                        <div style="width: 160px">
                            <el-input v-model="form.htbh" placeholder="请输入合同编号" clearable @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <el-form-item label="档案编号:">
                        <div style="width: 160px">
                            <el-input v-model="form.dabh" placeholder="请输入档案编号" clearable @keyup.enter.native="onSearch"></el-input>
                        </div>
                    </el-form-item>
                    <!-- <el-form-item label="房管员:">
                        <div style="width: 160px">
                            <el-select v-model="form.fgy" placeholder="请选择房管员" clearable @change="onSearch">
                                <el-option v-for="item in fgylist" :key="item.id" :label="item.name" :value="item.id"> </el-option>
                            </el-select>
                        </div>
                    </el-form-item> -->
                    <el-form-item>
                        <el-button type="primary" @click="onSearch" icon="el-icon-search" class="searchcolor">查询</el-button>
                        <el-button @click="reSearch" icon="el-icon-refresh" class="searchcolor">重置</el-button>
                    </el-form-item>
                </el-form>
                <div style="margin-bottom: 10px;">
                    <el-button type="primary" @click="yzyclick('2', '退件')" class="searchcolor" size="mini">退件</el-button>
                    <el-button type="primary" @click="yzyclick('1', '通过')" class="searchcolor" size="mini">通过</el-button>
                </div>
            </div>
            <!-- max-height="330" -->
            <el-table
                max-height="330"
                :data="tableData"
                style="width: 100%"
                :header-cell-style="tableHeaderColor"
                :row-style="tablerowColor"
                :row-class-name="tableRowClassName"
                :cell-style="tablecellColor"
                @selection-change="handleSelectionChange"
                border
            >
                <el-table-column type="selection" width="55" fixed> </el-table-column>
                <!-- <el-table-column prop="htbh" label="合同编号" align="center" width="130"> </el-table-column>
                <el-table-column prop="skrq" label="交款日期" align="center" width="100">
                    <template slot-scope="scope">
                        {{ scope.row.jkrq ? scope.row.jkrq.split(' ')[0] : '' }}
                    </template>
                </el-table-column>
                <el-table-column prop="dzzt" label="对账状态" align="center" width="130">
                    <template slot-scope="scope">
                        {{ scope.row.dzzt == '0' ? '未报账' : scope.row.dzzt == '1' ? '退回' :
                            scope.row.dzzt == '2' ? '通过' : scope.row.dzzt == '3' ? '单位待审核' : scope.row.dzzt == '4' ? '经租待审核':scope.row.dzzt == '5' ? '财务待审核':'' }}
                    </template>
                </el-table-column>
                <el-table-column prop="jfk" label="交返款" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.jfk == '1' ? '交款' : scope.row.jfk == '2' ? '返款' : '' }}
                    </template>
                </el-table-column>
                <el-table-column prop="ysqje" label="已收金额" align="center"> </el-table-column>
                <el-table-column prop="ysje" label="预收金额" align="center"> </el-table-column>
                <el-table-column prop="yzyje" label="预转已金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="jqtje" label="缴其他金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="sqje" label="税前金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="she" label="税额" align="center" width="100"> </el-table-column>
                <el-table-column prop="shje" label="税后金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="czr" label="承租单位" align="center" :show-overflow-tooltip="true" width="240"> </el-table-column>
                <el-table-column prop="zjlb" label="收租方式" align="center"> </el-table-column>
                <el-table-column prop="zph" label="支票号" align="center"> </el-table-column>
                <el-table-column prop="jyjje" label="缴押金金额" align="center" width="100"> </el-table-column> -->
                <!-- <el-table-column label="操作" width="120" align="center" fixed="right">
                    
                    <template slot-scope="scope">
                        <router-link :to="{ name: 'dzdetail', params: { id: scope.row.id} }">
                            <el-button type="text" size="small">查看</el-button>
                        </router-link>
                        <el-button type="text" size="small" @click="deleteClick(scope.row)"
                            style="color: red;margin-left: 12px;">删除</el-button>
                    </template>
                </el-table-column> -->
               
                <el-table-column prop="skrq" label="交款日期" align="center" width="100">
                    <template slot-scope="scope">
                        {{ scope.row.jkrq ? scope.row.jkrq.split(' ')[0] : '' }}
                    </template>
                </el-table-column>
                <el-table-column prop="dzzt" label="对账状态" align="center" width="120">
                    <template slot-scope="scope">
                        {{
                            scope.row.dzzt == '0'
                                ? '未报账'
                                : scope.row.dzzt == '1'
                                ? '退回'
                                : scope.row.dzzt == '2'
                                ? '通过'
                                : scope.row.dzzt == '3'
                                ? '单位待审核'
                                : scope.row.dzzt == '4'
                                ? '经租待审核'
                                : scope.row.dzzt == '5'
                                ? '财务待审核'
                                : ''
                        }}
                    </template>
                </el-table-column>
                <el-table-column prop="jfk" label="交返款" align="center">
                    <template slot-scope="scope">
                        {{ scope.row.jfk == '1' ? '交款' : scope.row.jfk == '2' ? '返款' : '' }}
                    </template>
                </el-table-column>
                <el-table-column prop="ysqje" label="已收金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="ysje" label="预收金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="yzyje" label="预转已金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="jqtje" label="缴其他金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="sqje" label="税前金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="she" label="税额" align="center" width="100"> </el-table-column>
                <el-table-column prop="shje" label="税后金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="zjlb" label="收租方式" align="center"> </el-table-column>
                <el-table-column prop="zph" label="支票号" align="center"> </el-table-column>
                <el-table-column prop="jyjje" label="缴（退）押金金额" align="center" width="140"> </el-table-column>
                <el-table-column prop="zsje" label="增收金额" align="center" width="100"> </el-table-column>
                <el-table-column prop="tkje" label="退款金额" align="center" width="140"> </el-table-column>
                <el-table-column prop="htbh" label="合同编号" align="center" width="160"> </el-table-column>
                <el-table-column prop="dabh" label="档案编号" align="center" width="240" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="fwdz" label="房屋地址" align="center" width="280" :show-overflow-tooltip="true"> </el-table-column>
                <el-table-column prop="czr" label="承租单位" align="center" width="280"> </el-table-column>
                <el-table-column prop="bz" label="备注" align="center" :show-overflow-tooltip="true" width="240"> </el-table-column>
                <el-table-column label="操作" width="60" align="center" fixed="right">
                    <template slot-scope="scope">
                        <router-link :to="{ name: 'dzdetailjlb', query: { id: scope.row.id } }">
                            <el-button type="text" size="small">查看</el-button>
                        </router-link>
                    </template>
                </el-table-column>
            </el-table>
            <div class="pagination" style="float: right">
                <el-pagination
                    background
                    layout="total,prev, pager, next,jumper"
                    :total="total"
                    :current-page.sync="current"
                    :page-size="pageSize"
                    :page-sizes="[10, 20, 30, 40, 50, 100]"
                    @current-change="handleCurrentChange"
                    @size-change="handleSizeChange"
                >
                </el-pagination>
            </div>
        </div>
    </div>
</template>

<script>
import { jlbdzlist, dzdelete, dzupdatejlb, getfgyList } from '@/api/index';
import valueList from '@/components/common/valueList.vue';
export default {
    name: 'jlbdzlist',
    data() {
        return {
            fgylist: [],
            dzztlist: valueList.dzztlist, //对账状态
            total: 0,
            current: 1,
            pageSize: 10,
            form: {
                bjqje: '', // 补旧欠金额 ,
                bz: '', // 备注 ,
                create_name: '', // 创建人 ,
                create_name_id: '', // 创建人id ,
                create_time: '', // 创建时间 ,
                current: 1, // 第几页 ,
                czr: '', // 承租单位 ,
                dabh: '', // 档案编号 ,
                dzzt: '', // 对账状态 0：未报账 1：已报账 2：通过 3：退回,
                htbh: '', // 合同编号 ,
                id: '',
                jfk: null, // 交返款 1：交款 2：返款,
                jkrq: '', // 交款日期 ,
                jqtje: '', // 缴其他金额 ,
                pageSize: 10, // 每页数量 ,
                she: '', // 税额 ,
                shje: '', // 税后金额 ,
                sqje: '', // 税前金额(实收金额),
                status_code: '1', // 1正常 2删除,
                update_name: '', // 修改人 ,
                update_name_id: '', // 修改人id ,
                update_time: '', // 修改时间 ,
                ysje: '', // 预收金额（转入预收金额） ,
                ysqje: '', // 已收金额 ,
                yzyje: '', // 预转已金额（预收转为已收金额） ,
                zjlb: '', // 收租方式 ,
                zph: '', // 支票号
                role: this.$store.getters.role, //角色
                type:this.$store.getters.type,//角色
                stdwid: this.$store.getters.company ? (this.$store.getters.company != 'null' ? this.$store.getters.company : '') : '',
                // glfs: this.$store.getters.company ? (this.$store.getters.company != 'null' ? '委托管理' : '') : '',
                fgy:''
            },
            tableData: [],
            multipleSelection: [] //确认选中列表
        };
    },
    components: {},
    computed: {
        // 判断变色
        getcolorred(htzt) {
            console.log(htzt);
            return (htzt) => {
                if (htzt == '正常') {
                    return { color: '#19BE6B', fontWeight: 700 };
                } else if (htzt == '已经到期') {
                    return { color: '#D9001B', fontWeight: 700 };
                } else if (htzt == '即将到期') {
                    return { color: '#FF9900', fontWeight: 700 };
                } else if (htzt == '未签合同') {
                    return { color: '#409ee1', fontWeight: 700 };
                }
            };
        }
    },
    methods: {
        // 列表样式
        tableHeaderColor({ row, column, rowIndex, columnIndex }) {
            if (rowIndex === 0) {
                return 'background:linear-gradient(to bottom, #008A94,#0ae2f2)!important;color:#ffffff;font-size:14px;';
            }
        },
        tablerowColor({ row, rowIndex }) {
            return 'height: 42px;font-size:14px;color:black';
        },
        tablecellColor() {
            return 'font-weight:700;color:#000000;border-color:#c0c0c0';
        },
        tableRowClassName({ row, rowIndex }) {
            if (rowIndex % 2 != 0) {
                return 'success-row'; //这是类名
            } else {
                return '';
            }
        },
        // 换页
        handleCurrentChange(val) {
            this.current = val;
            this.form.current = val;
            this.jlbdzlist(this.form);
            console.log(val);
        },
        // 每页条数
        handleSizeChange(val) {
            this.current = 1;
            this.pageSize = val;
            this.form.pageSize = val;
            this.jlbdzlist(this.form);
            console.log(val);
        },
        // 搜索
        onSearch() {
            this.current = 1;
            this.form.current = 1;
            this.jlbdzlist(this.form);
            console.log('搜索');
        },
        // 重置
        reSearch() {
            this.current = 1;
            this.form = {
                bjqje: '', // 补旧欠金额 ,
                bz: '', // 备注 ,
                create_name: '', // 创建人 ,
                create_name_id: '', // 创建人id ,
                create_time: '', // 创建时间 ,
                current: 1, // 第几页 ,
                czr: '', // 承租单位 ,
                dabh: '', // 档案编号 ,
                dzzt: '1', // 对账状态 0：未报账 1：已报账 2：通过 3：退回,
                htbh: '', // 合同编号 ,
                id: '',
                jfk: null, // 交返款 1：交款 2：返款,
                jkrq: '', // 交款日期 ,
                jqtje: '', // 缴其他金额 ,
                pageSize: 10, // 每页数量 ,
                she: '', // 税额 ,
                shje: '', // 税后金额 ,
                sqje: '', // 税前金额(实收金额),
                status_code: '1', // 1正常 2删除,
                update_name: '', // 修改人 ,
                update_name_id: '', // 修改人id ,
                update_time: '', // 修改时间 ,
                ysje: '', // 预收金额（转入预收金额） ,
                ysqje: '', // 已收金额 ,
                yzyje: '', // 预转已金额（预收转为已收金额） ,
                zjlb: '', // 收租方式 ,
                zph: '', // 支票号
                role: this.$store.getters.role, //角色
                type:this.$store.getters.type,//角色
                stdwid: this.$store.getters.company ? (this.$store.getters.company != 'null' ? this.$store.getters.company : '') : '',
                fgy: ''
            };
            this.jlbdzlist(this.form);
            console.log('搜索');
        },
        // 添加
        addnew() {
            this.$router.push({
                name: 'addproject',
                path: '/addproject'
            });
        },
        // 删除
        deleteClick(e) {
            console.log(e);
            this.$confirm('确定删除此条信息吗？')
                .then(() => {
                    let data = e.id;
                    dzdelete(data).then((res) => {
                        if (res.code == 200) {
                            this.jlbdzlist(this.form);
                            this.$message.success('删除成功');
                        }
                    });
                })
                .catch(() => {
                    this.$message.success('删除取消');
                });
        },
        // 对账列表
        jlbdzlist(data) {
            jlbdzlist(data).then((res) => {
                if (res.code == 200) {
                    this.tableData = res.data.records;
                    this.total = res.data.total;
                } else {
                    this.tableData = [];
                    this.total = 0;
                }
            });
        },
        // 对账状态确认
        dzupdatejlb(data) {
            dzupdatejlb(data).then((res) => {
                this.$message.success('已提交');
                this.jlbdzlist(this.form);
            });
        },
        // 多条报账点击事件
        handleSelectionChange(val) {
            console.log('val', val);
            this.multipleSelection = val;
        },
        // 报账按钮
        yzyclick(num, val) {
            this.$confirm(`确定执行【${val}】操作吗？`)
                .then(() => {
                    let data = {
                        dzzt: num, //对账状态 0：未报账 1：退回 2：通过 3：单位待审核 4：经租待审核 4：财务待审核
                        jflist: this.multipleSelection
                    };
                    console.log('报账', data);
                    this.dzupdatejlb(data);
                    this.$message.success('操作成功');
                })
                .catch(() => {
                    this.$message('操作取消');
                });
        },
        // 获取房管员列表
        getfgyList() {
            let data = {};
            getfgyList(data).then((res) => {
                if (res.code == 200) {
                    this.fgylist = res.data;
                } else {
                    this.$message.error = '获取数据失败！！';
                }
            });
        }
    },
    mounted() {
        // 获取房管员列表
        // this.getfgyList();
        this.jlbdzlist(this.form);
    }
};
</script>

<style scoped>
.container {
    /* height: calc(100vh - 260px); */
    overflow: hidden;
}

.crumbs {
    background-color: #fff;
    padding: 20px 20px;
}

.indexTitle {
    margin-bottom: 20px;
}

.contentsize {
    font-size: 18px;
    font-weight: 700;
}

.handle-box {
    overflow: hidden;
}

/* 新增按钮 */
.addcolor {
    margin-bottom: 10px;
}
</style>
<style>
.success-row {
    background-color: #eaf3fb !important;
}
</style>
